#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int _width(int tmp)
{
	int width = 0;
	while (tmp > 0)
	{
		tmp /= 10;
		width++;
	}
	return width;
}
int main() {
	int n = 0;
	scanf("%d", &n);
	int count = 0;
	for (int i = 0; i <= n; i++)
	{
		int p = pow(i, 2);
		int q = pow(10, _width(i));
		if (p % q == i)
		{
			//printf("%d ", i);
			count++;
		}
	}
	printf("%d", count);
	return 0;
}